const MyPromise = require('./myPromise')
function testMyPromise () {
  return new MyPromise((resolve, reject) => {
    setTimeout(() => {
      resolve('sleep 2000ms')
    }, 2000)
    reject('error')
  })
}
testMyPromise()
  .then(
    (data) => console.log(data, 'then data')
    // ,reason => console.log(reason, 'then reason')
  )

/*
// 原生的promise
function testPromise(){
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve('sleep 2000ms')
    }, 2000)
    // resolve(1)
    // reject('this is a error')
  })
}
testPromise()
  .then(
    (data) => console.log(data)
    // , (error) => console.log(error)
  )
  .catch(error => console.log(error))
  .finally(() => console.log('finally'))
  .then(data => console.log('f', data))

Promise.resolve(1).then(data => console.log(data))
Promise.all([1, testPromise()]).then(data => console.log(data))
*/